package com.csw.flink.transformation

import org.apache.flink.api.common.functions.FilterFunction
import org.apache.flink.streaming.api.scala._

object Demo03Filter {
  def main(args: Array[String]): Unit = {

    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    env.setParallelism(1)

    val ds: DataStream[String] = env.socketTextStream("master", 8888)

    //jscala的方法
    val ds1: DataStream[String] = ds.filter(value => value.equals("csw"))

    //java的方法
    var ds2: DataStream[String] = ds.filter(new FilterFunction[String] {
      override def filter(value: String): Boolean = {
        value.equals("csw")
      }
    })

    ds2.print()
    env.execute()
  }
}
